<?php


namespace App\Admin\Controllers\Export;

use App\Exports\TurnoverExport;
use Encore\Admin\Layout\Content;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Facades\Excel;

/**
 * Created By FreeAbrams
 * Date: 2020/11/26
 */
class TurnoverExportController extends Controller
{
	public function index(Content $content)
	{
		return $content->header('营业报表导出')
	        ->title('营业报表导出')
			->row(view('admin.export.year-select', [
				'route' => route('turnoverExport'),
				'routeIndex' => route('turnoverExport.index')
			]));
	}
	
	public function export(Request $request)
	{
		$timeBetween = $this->requestReturnTimeBetween($request);
		if(empty($timeBetween)) {
			return false;
		}

		return Excel::download(new TurnoverExport($timeBetween), '营业.xls');
	}
}